function setCookie(cname: string, cvalue: any, exdays: number) {
  const d = new Date();
  d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);
  const expires = 'expires=' + d.toLocaleDateString();
  document.cookie = cname + '=' + cvalue + '; ' + expires;
}
function getCookie(cname: string) {
  const name = cname + '=';
  const ca = document.cookie.split(';');
  for (let i = 0; i < ca.length; i++) {
    const c = ca[i].trim();
    if (c.indexOf(name) == 0) {
      return c.substring(name.length, c.length);
    }
  }
  return '';
}
function checkCookie(cname: string): Promise<boolean> {
  const user = getCookie(cname);
  if (user) {
    return Promise.resolve(true);
  } else {
    return Promise.resolve(false);
  }
}
export { setCookie, getCookie, checkCookie };
